import ACT from '../actionType'
import { connect } from 'react-redux'

/**
 *用户列表模块action
 */
export const action = {
  getUserList: param => {
    return {
      types: [ACT.USER_USERLIST_GET],
      promise: ajax => ajax.post('/user/userList', { ...param }),
      meta: param
    }
  }
}

//###########
//固定数据
//###########
//用户列表--表格头thead
const userTableHeader = [
  {
    title: '用户名称',
    dataIndex: 'name',
    key: 'name',
    sorter: true
  },
  {
    title: '手机号',
    dataIndex: 'phone',
    key: 'phone'
  },
  {
    title: '收货人',
    dataIndex: 'consignee',
    key: 'consignee'
  },
  {
    title: '联系电话',
    dataIndex: 'tel',
    key: 'tel'
  },
  {
    title: '收货地址',
    dataIndex: 'address',
    key: 'address'
  },
  {
    title: '邮政编码',
    dataIndex: 'zipCode',
    key: 'zipCode'
  }
]

/**
 * 取出数据和绑定方法
 */
export const userReduce = connect(
  //取出数据
  state => ({
    //all: console.log('state', state) || state,
    userList: state.User.userList,
    userTableHeader
  }),
  action
)

export const userReduce2 = connect(
  //取出数据
  state => ({
    //all: console.log('state', state) || state,
    userList: state.User.userList,
    userTableHeader
  }),
  action
)
